# Author : wyq
# 携程
import time
# 异步IO的雏形
# 消费者
def consumer(name):
    print("%s 准备吃包子" %name)
    while True:
        baozi = yield
        print("包子[%s]来了，被[%s]吃了"%(baozi,name))

def producer():
    c1 = consumer('a食客')
    c2 = consumer('b食客')
    c1.__next__()
    c2.__next__()
    print("厨师做包子")
    for i in range(10):
        time.sleep(1)
        print("一个包子分两半，A,B各一半")
        c1.send(i)
        c2.send(i)

producer()